package project.gui.creators;



import framework.events.Event;
import framework.gui.GUI;
import framework.gui.GUIObject;
import framework.gui.GUIObjectCreator;
import project.events.antEvents.FeasibilityAntCreatedEvent;
import project.events.antEvents.FeasibilityAntDiedEvent;
import project.gui.objects.GUIFeasibilityAnt;

public class GUIFeasibilityAntCreator extends GUIObjectCreator {

	public GUIFeasibilityAntCreator(GUI gui) {
		super(gui);
	}

	@Override
	protected GUIObject createGUIObject(Event event) {
		if (event instanceof FeasibilityAntCreatedEvent) {
//			System.out.println("GUI feasibility ant creator");
			FeasibilityAntCreatedEvent e = (FeasibilityAntCreatedEvent) event;
			return new GUIFeasibilityAnt(e.getId(), e.getPosition());
		} else {
			throw new IllegalStateException();
		}
	}

	@Override
	protected Class<? extends Event> getCreationEventClass() {
		return FeasibilityAntCreatedEvent.class;
	}

	@Override
	protected Class<? extends Event> getDestroyEventClass() {
		return FeasibilityAntDiedEvent.class;
	}

	@Override
	protected GUIObject getDestroyGUIObject(Event event) {
		if (event instanceof FeasibilityAntDiedEvent) {
			FeasibilityAntDiedEvent e = (FeasibilityAntDiedEvent) event;
			return new GUIFeasibilityAnt(e.getId(), null);
		} else {
			throw new IllegalStateException();
		}
	}
}
